{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# The ``inline`` flag will use the appropriate backend to make figures appear inline in the notebook.  \n",
    "%matplotlib inline\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "# `plt` is an alias for the `matplotlib.pyplot` module\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# import seaborn library (wrapper of matplotlib)\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Load Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load car loan data into a pandas dataframe from a csv file\n",
    "filename = 'data/table_i702t60.csv'\n",
    "df = pd.read_csv(filename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# View the first 5 rows of the dataframe\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Checking to make sure we dont have nans in our dataframe\n",
    "# It is not easy to directly plot data that contains nans\n",
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# For this notebook we will graph interest_paid, principal_paid, and month on one graph\n",
    "# While we could graph directly through pandas, we will graph through matplotlib for now.\n",
    "month_number = df.loc[:, 'month'].values\n",
    "interest_paid = df.loc[:, 'interest_paid'].values\n",
    "principal_paid = df.loc[:, 'principal_paid'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "month_number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# The values attribute converts a column of values into a numpy array\n",
    "type(month_number)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Changing Marker Type and Colors\n",
    "\n",
    "### Marker Type\n",
    "Here are a couple common marker types. \n",
    "\n",
    "string | description\n",
    "--- | ---\n",
    "'.' | point marker\n",
    "',' | pixel marker\n",
    "'o' | circle marker\n",
    "'v' | triangle_down marker\n",
    "'^' | triangle_up marker\n",
    "'<' | triangle_left marker\n",
    "'>' | triangle_right marker\n",
    "'s'\t| square marker\n",
    "'\\*' | star marker\n",
    "'+' | plus marker\n",
    "'x' | x marker\n",
    "'s'\t| square marker"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.style.use('seaborn')\n",
    "\n",
    "plt.plot(month_number, interest_paid)\n",
    "plt.plot(month_number, principal_paid, marker = '.', markersize = 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Change Color\n",
    "The `c` parameter accepts strings.\n",
    "\n",
    "string | color\n",
    "--- | ---\n",
    "'b' | blue\n",
    "'blue' | blue\n",
    "'g' | green\n",
    "'green' | green\n",
    "'r' | red\n",
    "'red' | red\n",
    "'c' | cyan\n",
    "'cyan' | cyan\n",
    "'m' | magenta\n",
    "'magenta' | magenta\n",
    "'y' | yellow\n",
    "'yellow' | yellow\n",
    "'k' | black\n",
    "'black' | black\n",
    "'w' | white\n",
    "'white' | white\n",
    "\n",
    "The parameter also accepts hex strings. For instance, green is '#008000'. Additionally you can use rgb tuples. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(month_number, interest_paid,c = 'k', marker = '.', markersize = 10)\n",
    "plt.plot(month_number, principal_paid,c = 'b', marker = '.', markersize = 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Using hex strings\n",
    "# '#000000' is black\n",
    "# '#0000FF' is blue\n",
    "plt.plot(month_number, interest_paid,c = '#000000', marker = '.', markersize = 10)\n",
    "plt.plot(month_number, principal_paid,c = '#0000FF', marker = '.', markersize = 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# Using rgb tuples\n",
    "# (0, 0, 0) is black\n",
    "# (0, 0, 1) is blue\n",
    "plt.plot(month_number, interest_paid,c = (0, 0, 0), marker = '.', markersize = 10)\n",
    "plt.plot(month_number, principal_paid,c = (0, 0, 1), marker = '.', markersize = 10)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
